(*
	SPortBufferSize() -- Returns the size of the current input buffer, or zero if the default buffer is
		begin used.

	To compile and link this file using Macintosh Programmer's Workshop,

		pascal -w SPortBufferSize.p
		link -m ENTRYPOINT -o HyperCommands -rt XFCN=7034 -sn Main=SPortBufferSize ¶
			SPortBufferSize.p.o "{MPW}"Libraries:interface.o

	© Copyright 1987,88 by Apple Computer, Inc.

	Initial coding 9/87 by Harry R. Chesley.
*)

{$R-}

{$S SPortBufferSize } 	{ Segment name must be the same as the command name. }

unit DummyUnit;

interface

uses MemTypes, QuickDraw, OSIntf, HyperXCmd;

procedure EntryPoint(paramPtr: XCmdPtr);
	
implementation

type

Str31 = String[31];

procedure SPortBufferSize(paramPtr: XCmdPtr); forward;

procedure EntryPoint(paramPtr: XCmdPtr);

	begin
		SPortBufferSize(paramPtr);
	end;

procedure SPortBufferSize(paramPtr: XCmdPtr);

	var l: longInt;

	{$I XCmdGlue.inc}

	procedure Fail(errMsg: Str255); { set theResult and quit }
		begin
			paramPtr^.returnValue := PasToZero(errMsg);
			exit(SPortBufferSize);
		end;

	{$I SPortUtil.inc}

	begin
		if paramPtr^.paramCount <> 0 then Fail('parameter count is not 0');

		SetUpSPortGlobals;
		EnsureOpenPort;

		{ Find and return the size of the current buffer (or zero if the default buffer is being used). }
		if ThisSPort.inputBuffer = nil then l := 0
		else l := GetPtrSize(ThisSPort.inputBuffer);
		paramPtr^.returnValue := PasToZero(LongToStr(l))
	end;
end.
